package com.ruoyi.web.controller.snmp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpSensorsubject;
import com.ruoyi.system.service.ISnmpSensorsubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 传感器主题信息Controller
 *
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/snmp/sensorsubject")
public class SnmpSensorsubjectController extends BaseController
{
    @Autowired
    private ISnmpSensorsubjectService snmpSensorsubjectService;

    /**
     * 查询传感器主题信息列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorsubject:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpSensorsubject snmpSensorsubject)
    {
        startPage();
        List<SnmpSensorsubject> list = snmpSensorsubjectService.selectSnmpSensorsubjectList(snmpSensorsubject);
        return getDataTable(list);
    }

    /**
     * 导出传感器主题信息列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorsubject:export')")
    @Log(title = "传感器主题信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpSensorsubject snmpSensorsubject)
    {
        List<SnmpSensorsubject> list = snmpSensorsubjectService.selectSnmpSensorsubjectList(snmpSensorsubject);
        ExcelUtil<SnmpSensorsubject> util = new ExcelUtil<SnmpSensorsubject>(SnmpSensorsubject.class);
        util.exportExcel(response, list, "传感器主题信息数据");
    }

    /**
     * 获取传感器主题信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorsubject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(snmpSensorsubjectService.selectSnmpSensorsubjectById(id));
    }

    /**
     * 新增传感器主题信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorsubject:add')")
    @Log(title = "传感器主题信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpSensorsubject snmpSensorsubject)
    {
        return toAjax(snmpSensorsubjectService.insertSnmpSensorsubject(snmpSensorsubject));
    }

    /**
     * 修改传感器主题信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorsubject:edit')")
    @Log(title = "传感器主题信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpSensorsubject snmpSensorsubject)
    {
        return toAjax(snmpSensorsubjectService.updateSnmpSensorsubject(snmpSensorsubject));
    }

    /**
     * 删除传感器主题信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorsubject:remove')")
    @Log(title = "传感器主题信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(snmpSensorsubjectService.deleteSnmpSensorsubjectByIds(ids));
    }
}
